#pragma once

#include "VSceneEntity.h"

class VMaterial;

enum EVHelperSubMeshType
{
	VHSMT_SPHERE = 0,
	VHSMT_BOX,
	VHSMT_CAPSUL,
	VHSMT_CONE,
};

class VHelperRenderMesh : public VRenderMesh
{
public:
	struct CommonVertex
	{
		VVector3 Position;
		VVector2 TexCoord;		// half ????
		VByteVector Normal;
	};

	struct NormalVertex
	{
		VByteVector Tangent;
		VByteVector BiNormal;
	};
	VRVertexBufferPtr m_CommonVertexBuffer;
	VRVertexBufferPtr m_NormalVertexBuffer;

	VHelperRenderMesh():VRenderMesh(VRMT_STATIC_MESH, 0)
	{
	}
	void InitRenderResources();
	virtual void RT_Init();
	virtual void RT_Shutdown();
	virtual void RT_BeginReset();
	virtual void RT_EndReset();
	virtual void* CreateMaterialBindInfo(VMaterial* Material, BOOL DepthOnly){ return (void*)0;}
	virtual void DestroyMaterialBindInfo(void* BindInfo, BOOL DepthOnly) {}
protected:
	void RT_InitVertexDeclaration();
	virtual void RT_SetDepthStreams(void* MaterialBindInfo);
	virtual void RT_SetStreams(void* MaterialBindInfo);
	virtual VRVertexDeclaration* RT_GetVertexDeclaration(void* MaterialBindInfo) const;
};

class VHelperComponentSceneProxy : public VSceneEntityAgent
{
public:

protected:
	virtual void RT_Init();
protected:
	VHelperRenderMesh* m_RenderMesh;
};

class VCoreApi VSimpleEntity : public VSceneEntity
{
public:
	VSimpleEntity(void);
	~VSimpleEntity(void);
	void InitRenderResources();
protected:
	void RT_InitRenderResources();
	
protected:
	VColor				m_Color;
	VMaterial*			m_Material;
};

class VCoreApi VSphereEntity : public VSimpleEntity
{
	virtual VSceneEntityAgent* CreateSceneAgent();
public:
	VSphereEntity():m_Radius(1.0f), m_Sides(8),m_MeshDirty(TRUE){}
	~VSphereEntity(){}
	void SetRadius(float Radius);
	void SetSides(int Sides);

	BOOL UpdateRenderMesh();

	inline float GetRadius() const { return m_Radius;}
	inline int GetSides() const { return m_Sides; }
protected:
	float			m_Radius;
	int				m_Sides;
	BOOL			m_MeshDirty;
};

class VBoxEntity : public VSimpleEntity
{

};



class VConeEntity : public VSimpleEntity
{

};
